package cn.daomeng.firebird.core.exception;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.LocaleResolver;

/**
 * @description:
 * @author: wangcheng04
 * @create: 2019-04-01 18:35
 **/

public class LangLocaleResolver implements LocaleResolver {
    private static final String LANG = "Accept-Language";
    private static final String LANG_SESSION = "lang_session";

    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        String lauage = request.getHeader(LANG);
        //默认没有就是请求地区的语言
        Locale locale=Locale.CHINESE;
        if("en-US".equals(lauage)){
            locale=Locale.ENGLISH;
        }
        return locale;
    }

    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {

    }
}
